package com.xdjd.mobile.business.constant;

import org.apache.commons.lang.StringUtils;

/**
 * 交易渠道类型枚举
 *
 * @author panjl
 */
public enum TradeChannelEnum {

    alipay(0, "支付宝"),
    weixin(1, "微信");


    /**
     * 验证码业务类型代码
     */
    private Integer code;

    /**
     * 验证码业务类型描述
     */
    private String desc;

    private TradeChannelEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static TradeChannelEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        TradeChannelEnum sts = null;
        for (TradeChannelEnum stsEnum : TradeChannelEnum.values()) {
            if (stsEnum.getCode().equals(code)) {
                sts = stsEnum;
                break;
            }
        }
        return sts;
    }

    public static TradeChannelEnum getByDesc(String desc) {
        if (StringUtils.isEmpty(desc)) {
            return null;
        }
        TradeChannelEnum sts = null;
        for (TradeChannelEnum stsEnum : TradeChannelEnum.values()) {
            if (stsEnum.getDesc().equals(desc)) {
                sts = stsEnum;
                break;
            }
        }
        return sts;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

}
